(function(){

var now = { row:1, col:1 }, last = { row:0, col:0};
const towards = { up:1, right:2, down:3, left:4};
var isAnimating = false;
var maxPage = 16;

document.addEventListener("touchmove",function(event){
	event.preventDefault(); },false);

function pageMove(tw){
	var lastPage = ".page-"+last.row+"-"+last.col,
		nowPage = ".page-"+now.row+"-"+now.col;
	
	switch(tw) {
		case towards.up:
			outClass = "page-moveToTop";
			inClass = "page-moveFromBottom";
			break;
		case towards.down:
			outClass = "page-moveToBottom";
			inClass = "page-moveFromTop";
			break;
	}
	isAnimating = true;
	$(nowPage).removeClass("hide");
	
	$(lastPage).addClass(outClass);
	$(nowPage).addClass(inClass);
	
	setTimeout(function(){
		$(lastPage).removeClass("page-current");
		$(lastPage).removeClass(outClass);
		$(lastPage).addClass("hide");
		$(lastPage).find("img").addClass("hide");
		$(lastPage).find(".text").addClass("hide");
		$(lastPage).children().find(".lineh").find("div").addClass("hide");
		
		$(nowPage).addClass("page-current");
		$(nowPage).removeClass(inClass);
		$(nowPage).find("img").removeClass("hide");
		$(nowPage).find(".text").removeClass("hide");
		$(nowPage).children().find(".lineh").find("div").removeClass("hide");
		
		isAnimating = false;
	},600);
}
})();

$(document).ready(function(){
	$('input[type="text"],textarea').focus(function(){
		$('p.foot').addClass('hide');
	})
	$('input[type="text"],textarea').blur(function(){
		$('p.foot').addClass('hide');
	})
})